/**
 * 详情对话框
 */
var TbOrderInfoDlg = {
    data: {
        payment: "",
        paymentType: "",
        postFee: "",
        status: "",
        createTime: "",
        updateTime: "",
        paymentTime: "",
        consignTime: "",
        endTime: "",
        closeTime: "",
        shippingName: "",
        shippingCode: "",
        userId: "",
        merId: "",
        buyerMessage: "",
        buyerNick: "",
        buyerComment: "",
        remarksUser:"",
        remarksSales:""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
   var ajax = new $ax(Feng.ctxPath + "/tbOrder/detail?orderId=" + Feng.getUrlParam("orderId"));
   // var ajax = new $ax(Feng.ctxPath + "/tbOrder/uploadDetail");
    var result = ajax.start();
    var statusArr = ["未付款", "已付款", "未发货", "已发货", "交易成功", "交易关闭", "交易失败"];
    var paymentTypeArr = ["在线支付", "货到付款"];
  /* $.ajax({
        url: "http://ca.mygjp.com:8002/api/zyx.selfbuiltmall.uploadsaleorders",
        data:result,
        type:"post",
        success: function(){
        alert(this.data);
        }
});*/
    result.data.statusDesc = statusArr[result.data.status];
    result.data.paymentTypeDesc = paymentTypeArr[result.data.paymentType - 1];
    form.val('tbOrderForm', result.data);

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/tbOrder'
    });
    //编辑按钮
    $("#bianji").click(function () {
        if($("#bianji").text()=="编辑"){
            $("#remarksSales").removeAttr("readonly");
            $("#remarksSales").get(0).focus();

            $("#bianji").text("提交")
        }else if($("#bianji").text()=="提交"){
            ajax = new $ax(Feng.ctxPath + "/tbOrder/updateS", function (data) {
                Feng.success("操作成功!");
            }, function (data) {
                Feng.error("操作失败!" + data.responseJSON.message + "!");
            });
            ajax.set("orderId", Feng.getUrlParam("orderId"));
            ajax.set("remarksSales",$("#remarksSales").val());
            ajax.start();
            $("#remarksSales").attr("readonly","readonly");
            $("#bianji").text("编辑")

        }

    })
});

